VERSION 5.00
Begin VB.Form frmGraph 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "*"
   ClientHeight    =   5550
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7065
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   Icon            =   "frmGraph.frx":0000
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5550
   ScaleWidth      =   7065
   StartUpPosition =   2  'CenterScreen
   Begin VB.PictureBox picBackup 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   1200
      ScaleHeight     =   17
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   193
      TabIndex        =   30
      Top             =   5160
      Visible         =   0   'False
      Width           =   2895
   End
   Begin VB.Frame fmeSettings 
      Caption         =   "*"
      Height          =   3135
      Left            =   4200
      TabIndex        =   19
      Top             =   2280
      Width           =   2775
      Begin VB.CheckBox chkFeatures 
         Caption         =   "*"
         Height          =   255
         Index           =   2
         Left            =   1080
         TabIndex        =   29
         Top             =   2160
         Width           =   1575
      End
      Begin VB.CheckBox chkFeatures 
         Caption         =   "*"
         Height          =   255
         Index           =   1
         Left            =   1080
         TabIndex        =   28
         Top             =   1800
         Width           =   1575
      End
      Begin VB.CheckBox chkFeatures 
         Caption         =   "*"
         Height          =   255
         Index           =   0
         Left            =   1080
         TabIndex        =   27
         Top             =   1440
         Width           =   1575
      End
      Begin VB.CheckBox chkCalibration 
         Caption         =   "*"
         Height          =   255
         Left            =   1080
         TabIndex        =   25
         Top             =   960
         Width           =   1215
      End
      Begin VB.OptionButton optCalibration 
         Caption         =   "*"
         Height          =   255
         Index           =   3
         Left            =   1800
         TabIndex        =   24
         Top             =   600
         Width           =   495
      End
      Begin VB.OptionButton optCalibration 
         Caption         =   "*"
         Height          =   255
         Index           =   2
         Left            =   1080
         TabIndex        =   23
         Top             =   600
         Width           =   495
      End
      Begin VB.OptionButton optCalibration 
         Caption         =   "*"
         Height          =   255
         Index           =   1
         Left            =   1800
         TabIndex        =   22
         Top             =   360
         Width           =   495
      End
      Begin VB.OptionButton optCalibration 
         Caption         =   "*"
         Height          =   255
         Index           =   0
         Left            =   1080
         TabIndex        =   21
         Top             =   360
         Value           =   -1  'True
         Width           =   495
      End
      Begin VB.Label lblMessages 
         Caption         =   "*"
         Height          =   255
         Index           =   7
         Left            =   120
         TabIndex        =   26
         Top             =   1440
         Width           =   975
      End
      Begin VB.Label lblMessages 
         Caption         =   "*"
         Height          =   255
         Index           =   6
         Left            =   120
         TabIndex        =   20
         Top             =   360
         Width           =   975
      End
   End
   Begin VB.Frame fmeColor 
      Caption         =   "*"
      Height          =   2055
      Left            =   4200
      TabIndex        =   9
      Top             =   120
      Width           =   2775
      Begin VB.CommandButton cmdRandomize 
         Caption         =   "*"
         Height          =   375
         Left            =   1440
         TabIndex        =   18
         Top             =   1440
         Width           =   1095
      End
      Begin VB.PictureBox picPreview 
         Height          =   375
         Left            =   960
         ScaleHeight     =   315
         ScaleWidth      =   315
         TabIndex        =   13
         Top             =   1440
         Width           =   375
      End
      Begin VB.HScrollBar hsRGB 
         Height          =   255
         Index           =   2
         LargeChange     =   50
         Left            =   480
         Max             =   255
         Min             =   1
         SmallChange     =   10
         TabIndex        =   12
         Top             =   1080
         Value           =   1
         Width           =   2055
      End
      Begin VB.HScrollBar hsRGB 
         Height          =   255
         Index           =   1
         LargeChange     =   50
         Left            =   480
         Max             =   255
         Min             =   1
         SmallChange     =   10
         TabIndex        =   11
         Top             =   720
         Value           =   1
         Width           =   2055
      End
      Begin VB.HScrollBar hsRGB 
         Height          =   255
         Index           =   0
         LargeChange     =   50
         Left            =   480
         Max             =   255
         Min             =   1
         SmallChange     =   10
         TabIndex        =   10
         Top             =   360
         Value           =   1
         Width           =   2055
      End
      Begin VB.Label lblMessages 
         Caption         =   "*"
         Height          =   255
         Index           =   5
         Left            =   120
         TabIndex        =   17
         Top             =   1440
         Width           =   735
      End
      Begin VB.Label lblMessages 
         Caption         =   "*"
         Height          =   255
         Index           =   4
         Left            =   120
         TabIndex        =   16
         Top             =   1080
         Width           =   375
      End
      Begin VB.Label lblMessages 
         Caption         =   "*"
         Height          =   255
         Index           =   3
         Left            =   120
         TabIndex        =   15
         Top             =   720
         Width           =   375
      End
      Begin VB.Label lblMessages 
         Caption         =   "*"
         Height          =   255
         Index           =   2
         Left            =   120
         TabIndex        =   14
         Top             =   360
         Width           =   375
      End
   End
   Begin VB.PictureBox picDraw 
      AutoRedraw      =   -1  'True
      BackColor       =   &H00FFFFFF&
      Height          =   3615
      Left            =   120
      ScaleHeight     =   237
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   261
      TabIndex        =   7
      Top             =   1440
      Width           =   3975
      Begin VB.Label lblMessages 
         BackStyle       =   0  'Transparent
         Caption         =   "*"
         Height          =   255
         Index           =   9
         Left            =   3720
         TabIndex        =   32
         Top             =   1320
         Width           =   135
      End
      Begin VB.Label lblMessages 
         BackStyle       =   0  'Transparent
         Caption         =   "*"
         Height          =   255
         Index           =   8
         Left            =   2160
         TabIndex        =   31
         Top             =   0
         Width           =   135
      End
   End
   Begin VB.CommandButton cmdClear 
      Caption         =   "*"
      Height          =   375
      Left            =   3000
      TabIndex        =   6
      Top             =   960
      Width           =   1095
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "*"
      Height          =   375
      Left            =   1560
      TabIndex        =   5
      Top             =   960
      Width           =   1095
   End
   Begin VB.CommandButton cmdDraw 
      Caption         =   "*"
      Default         =   -1  'True
      Height          =   375
      Left            =   120
      TabIndex        =   4
      Top             =   960
      Width           =   1095
   End
   Begin VB.Frame fmeExpression 
      Caption         =   "*"
      Height          =   735
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   3975
      Begin VB.TextBox txtExpression 
         Height          =   285
         Left            =   1080
         TabIndex        =   3
         Top             =   240
         Width           =   2775
      End
      Begin VB.ComboBox cboXY 
         Height          =   315
         Left            =   120
         Style           =   2  'Dropdown List
         TabIndex        =   1
         Top             =   240
         Width           =   615
      End
      Begin VB.Label lblMessages 
         Caption         =   "*"
         Height          =   375
         Index           =   0
         Left            =   840
         TabIndex        =   2
         Top             =   240
         Width           =   135
      End
   End
   Begin VB.Label lblMessages 
      Caption         =   "*"
      Height          =   255
      Index           =   1
      Left            =   120
      TabIndex        =   8
      Top             =   5160
      Width           =   3975
   End
End
Attribute VB_Name = "frmGraph"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub chkCalibration_Click()
    On Error Resume Next
    RefreshAll
End Sub

Private Sub chkFeatures_Click(Index As Integer)
    On Error Resume Next
    RefreshAll
End Sub

Private Sub cmdCancel_Click()
    On Error Resume Next
    Unload frmGraph
End Sub

Private Sub cmdClear_Click()
    On Error Resume Next
    picDraw.Cls
    RefreshAll
End Sub

Private Sub cmdDraw_Click()
    On Error Resume Next
    Dim bpDraw As Boolean
    Dim strInput As String
    txtExpression.Enabled = False
    strInput = Trim(txtExpression.Text)
    lblMessages(1).Caption = LoadGlobalLanguage(407)
    cmdDraw.Enabled = False
    cmdClear.Enabled = False
    cmdCancel.Enabled = False
    If cboXY.ListIndex = 0 Then
        bpDraw = DrawFunctionY(picDraw, strInput, picPreview.BackColor, CBool(chkFeatures(1).Value))
    Else
        bpDraw = DrawFunctionX(picDraw, strInput, picPreview.BackColor, CBool(chkFeatures(1).Value))
    End If
    If bpDraw = False Then
        MsgBox LoadGlobalLanguage(428), vbCritical, LoadGlobalLanguage(16)
    End If
    cmdDraw.Enabled = True
    cmdClear.Enabled = True
    cmdCancel.Enabled = True
    If chkFeatures(0).Value = 1 Then
        Call cmdRandomize_Click
    End If
    lblMessages(1).Caption = LoadGlobalLanguage(406)
    txtExpression.Enabled = True
End Sub

Private Sub cmdRandomize_Click()
    On Error Resume Next
    Randomize
    hsRGB(0).Value = hsRGB(0).Min + Int(hsRGB(0).Max * Rnd)
    hsRGB(1).Value = hsRGB(1).Min + Int(hsRGB(1).Max * Rnd)
    hsRGB(2).Value = hsRGB(2).Min + Int(hsRGB(2).Max * Rnd)
    RefreshRGB
End Sub

Private Sub Form_Load()
    On Error Resume Next
    frmGraph.Caption = LoadGlobalLanguage(401)
    fmeExpression.Caption = LoadGlobalLanguage(402)
    fmeColor.Caption = LoadGlobalLanguage(408)
    fmeSettings.Caption = LoadGlobalLanguage(414)
    cmdDraw.Caption = LoadGlobalLanguage(403)
    cmdCancel.Caption = LoadGlobalLanguage(404)
    cmdClear.Caption = LoadGlobalLanguage(405)
    lblMessages(0).Caption = LoadGlobalLanguage(425)
    lblMessages(1).Caption = LoadGlobalLanguage(406)
    lblMessages(2).Caption = LoadGlobalLanguage(409)
    lblMessages(3).Caption = LoadGlobalLanguage(410)
    lblMessages(4).Caption = LoadGlobalLanguage(411)
    lblMessages(5).Caption = LoadGlobalLanguage(412)
    lblMessages(6).Caption = LoadGlobalLanguage(415)
    lblMessages(7).Caption = LoadGlobalLanguage(421)
    lblMessages(8).Caption = LoadGlobalLanguage(426)
    lblMessages(9).Caption = LoadGlobalLanguage(427)
    cmdRandomize.Caption = LoadGlobalLanguage(413)
    optCalibration(0).Caption = LoadGlobalLanguage(416)
    optCalibration(1).Caption = LoadGlobalLanguage(417)
    optCalibration(2).Caption = LoadGlobalLanguage(418)
    optCalibration(3).Caption = LoadGlobalLanguage(419)
    chkCalibration.Caption = LoadGlobalLanguage(420)
    chkFeatures(0).Caption = LoadGlobalLanguage(422)
    chkFeatures(1).Caption = LoadGlobalLanguage(423)
    chkFeatures(2).Caption = LoadGlobalLanguage(424)
    With cboXY
        .AddItem LoadGlobalLanguage(426)
        .AddItem LoadGlobalLanguage(427)
        .ListIndex = 0
    End With
    ReadSetup
    RefreshAll
End Sub

Private Sub RefreshAll()
    On Error Resume Next
    RefreshRGB
    If chkFeatures(2).Value = 1 Then
        picDraw.DrawWidth = 2
        picBackup.FontBold = True
        lblMessages(8).FontBold = True
        lblMessages(9).FontBold = True
    Else
        picDraw.DrawWidth = 1
        picBackup.FontBold = False
        lblMessages(8).FontBold = False
        lblMessages(9).FontBold = False
    End If
    If optCalibration(0).Value = True Then
        BuildXY picDraw, picBackup, 20, vbBlack, vbBlack, CBool(chkCalibration.Value)
    End If
    If optCalibration(1).Value = True Then
        BuildXY picDraw, picBackup, 30, vbBlack, vbBlack, CBool(chkCalibration.Value)
    End If
    If optCalibration(2).Value = True Then
        BuildXY picDraw, picBackup, 40, vbBlack, vbBlack, CBool(chkCalibration.Value)
    End If
    If optCalibration(3).Value = True Then
        BuildXY picDraw, picBackup, 60, vbBlack, vbBlack, CBool(chkCalibration.Value)
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    SaveSetup
    Cancel = False
    DoEvents
End Sub

Private Sub hsRGB_Change(Index As Integer)
    On Error Resume Next
    RefreshRGB
End Sub

Private Sub RefreshRGB()
    On Error Resume Next
    picPreview.BackColor = RGB(hsRGB(0).Value, hsRGB(1).Value, hsRGB(2).Value)
End Sub

Private Sub optCalibration_Click(Index As Integer)
    On Error Resume Next
    RefreshAll
End Sub

Private Sub SaveSetup()
    On Error Resume Next
    SaveSetting App.EXEName, "Graph\Calibration", "Enabled", Trim(Str(chkCalibration.Value))
    SaveSetting App.EXEName, "Graph\Features", "Feature1", Trim(Str(chkFeatures(0).Value))
    SaveSetting App.EXEName, "Graph\Features", "Feature2", Trim(Str(chkFeatures(1).Value))
    SaveSetting App.EXEName, "Graph\Features", "Feature3", Trim(Str(chkFeatures(2).Value))
    If optCalibration(0).Value = True Then
        SaveSetting App.EXEName, "Graph\Calibration", "Value", "0"
    End If
    If optCalibration(1).Value = True Then
        SaveSetting App.EXEName, "Graph\Calibration", "Value", "1"
    End If
    If optCalibration(2).Value = True Then
        SaveSetting App.EXEName, "Graph\Calibration", "Value", "2"
    End If
    If optCalibration(3).Value = True Then
        SaveSetting App.EXEName, "Graph\Calibration", "Value", "3"
    End If
    SaveSetting App.EXEName, "Graph\RGB", "R", Trim(Str(hsRGB(0).Value))
    SaveSetting App.EXEName, "Graph\RGB", "G", Trim(Str(hsRGB(1).Value))
    SaveSetting App.EXEName, "Graph\RGB", "B", Trim(Str(hsRGB(2).Value))
End Sub

Private Sub ReadSetup()
    On Error Resume Next
    Dim lpRead As Double
    chkCalibration.Value = LoadNumberSetup(App.EXEName, "Graph\Calibration", "Enabled", "0")
    chkFeatures(0).Value = LoadNumberSetup(App.EXEName, "Graph\Features", "Feature1", "0")
    chkFeatures(1).Value = LoadNumberSetup(App.EXEName, "Graph\Features", "Feature2", "0")
    chkFeatures(2).Value = LoadNumberSetup(App.EXEName, "Graph\Features", "Feature3", "0")
    Select Case LoadNumberSetup(App.EXEName, "Graph\Calibration", "Value", "0")
        Case 0
            optCalibration(0).Value = True
        Case 1
            optCalibration(1).Value = True
        Case 2
            optCalibration(2).Value = True
        Case 3
            optCalibration(3).Value = True
        Case Else
            optCalibration(0).Value = True
    End Select
    hsRGB(0).Value = LoadNumberSetup(App.EXEName, "Graph\RGB", "R", "1")
    hsRGB(1).Value = LoadNumberSetup(App.EXEName, "Graph\RGB", "G", "1")
    hsRGB(2).Value = LoadNumberSetup(App.EXEName, "Graph\RGB", "B", "1")
End Sub
